{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "乐学偶得版权所有 lexueoude.com 公众号：乐学Fintech"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "#include <stdio.h>\n",
    "\n",
    "//This is a comment at the begining of the program~\n",
    "int main(void)\n",
    "{\n",
    "int num;/* Statement */\n",
    "num=888;/* Statement */\n",
    "printf(\"Our favorite number is %d ,\\n because it means getting rich in Chinese.\",num);/* Statement */\n",
    "\n",
    "return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "header files:\n",
    "#include <stdio.h>\n",
    "\n",
    "standard input and output\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "function:\n",
    "int main(void)\n",
    "int means it will return an integer\n",
    "the fuction name is \"main\"\n",
    "\n",
    "old:   main() C90 BUT ! C99----X\n",
    "\n",
    "void main()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "comment:\n",
    "\n",
    "/*    This is a comment */\n",
    "\n",
    "\n",
    "C99+ : C++ AND JAVA \n",
    "\n",
    "//"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "{}:\n",
    "braces{}\n",
    "bracket[]\n",
    "parentheses()\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "declaration:\n",
    "\n",
    "num is a variable\n",
    "int\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "//Before they are used ,all variable MUST BE DECLARED!\n",
    "/*  Before C99 */\n",
    "int main()\n",
    "{\n",
    "int num_1;\n",
    "int num_2;\n",
    "int num_3;\n",
    "\n",
    "....\n",
    "\n",
    "\n",
    "}\n",
    "\n",
    "\n",
    "/* After C99 */\n",
    "\n",
    "int main()\n",
    "{\n",
    "//statements........\n",
    "int num_1;\n",
    "num_1=888;\n",
    "\n",
    "//statements........\n",
    "\n",
    "int num_2;\n",
    "num_2=999;\n",
    "\n",
    "//statements........\n",
    "\n",
    "\n",
    "\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "variable : integer,floating point,characters"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "printf(fuction函数)  以某种格式输出formatted （argument参数） 真实参数（actual argument）形式参数（formal argument）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "printf(\"Our favorite number is %d , \\nbecause it means getting rich in Chinese.\",num);\n",
    "\\n 转义字符 escape sequence"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "placeholder 占位 % d decimal（10）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "My favorite number is 888 , because it means getting rich in Chinese.\n",
      "William's favorite number is 666 ,because it means cool in Chinese."
     ]
    }
   ],
   "source": [
    "//This program tells you your favorite number and William's favorite number\n",
    "\n",
    "#include <stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "int num_1;\n",
    "int num_2;\n",
    "\n",
    "num_1=888;\n",
    "num_2=666;\n",
    "\n",
    "printf(\"My favorite number is %d , because it means getting rich in Chinese.\\n\",num_1);\n",
    "\n",
    "printf(\"William's favorite number is %d ,because it means cool in Chinese.\",num_2);\n",
    "\n",
    "return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "My favorite number is 888 , because it means getting rich in Chinese.\n",
      "William's favorite number is 7104 ,It is always 2 times of my favorite number."
     ]
    }
   ],
   "source": [
    "//This program tells you your favorite number and multiply it by 8 is William's favorite number\n",
    "\n",
    "#include <stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "int num_1;\n",
    "int num_2;\n",
    "\n",
    "num_1=888;\n",
    "num_2=8 * num_1;\n",
    "\n",
    "printf(\"My favorite number is %d , because it means getting rich in Chinese.\\n\",num_1);\n",
    "\n",
    "printf(\"William's favorite number is %d ,It is always 2 times of my favorite number.\",num_2);\n",
    "\n",
    "return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "//This program tells you your favorite number and multiply it by 8 is William's favorite number\n",
    "\n",
    "#include <stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "int num_1;\n",
    "int num_2;\n",
    "\n",
    "num_1=888;\n",
    "num_2=8 * num_1;\n",
    "\n",
    "printf(\"My favorite number is %d , because it means getting rich in Chinese.\\n\",num_1);\n",
    "\n",
    "printf(\"William's favorite number is %d ,It is always 2 times of my favorite number.\",num_2);\n",
    "\n",
    "return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I have three dragons!!!!\n",
      "MMMMMMMMMM........\n",
      "Now kill them!\n"
     ]
    }
   ],
   "source": [
    "//This program show you the dragon\n",
    "\n",
    "#include <stdio.h>\n",
    "\n",
    "void dragon(void);// prototype (function declaration)\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "    printf(\"I have three dragons!!!!\\n\");\n",
    "    dragon();// function call\n",
    "    printf(\"Now kill them!\\n\");\n",
    "\n",
    "return 0;\n",
    "}\n",
    "\n",
    "void dragon(void)//function definition\n",
    "{\n",
    "    printf(\"MMMMMMMMMM........\\n\");\n",
    "}\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C90之后：\n",
    "void dragon(void);// prototype (function declaration)\n",
    "\n",
    "prototype——>compiler\n",
    "void——> return empty\n",
    " \n",
    "void dragon(); C90 C99 C11 C18\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "My favorite number is 888 , because it means getting rich in Chinese.\n",
      "William's favorite number is 7104 ,It is always 2 times of my favorite number."
     ]
    }
   ],
   "source": [
    "//This program tells you your favorite number and multiply it by 8 is William's favorite number\n",
    "\n",
    "#include <stdio.h>\n",
    "\n",
    "int main(void)\n",
    "{\n",
    "int if_aaa;\n",
    "int num_2;\n",
    "\n",
    "if_aaa=888;\n",
    "num_2=8 * if_aaa;\n",
    "\n",
    "printf(\"My favorite number is %d , because it means getting rich in Chinese.\\n\",if_aaa);\n",
    "\n",
    "printf(\"William's favorite number is %d ,It is always 2 times of my favorite number.\",num_2);\n",
    "\n",
    "return 0;\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "reserved identifiers : if int float  for while "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C",
   "language": "c",
   "name": "c"
  },
  "language_info": {
   "file_extension": ".c",
   "mimetype": "text/plain",
   "name": "c"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
